#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

bool isValid(int i)
{
    while(i > 0) {
	if (i%10 == 4) return false;
	i /= 10;
    }
    return true;
}
static int cur = 0;

int getNum(int num)
{
    cur += 1;
    while (!isValid(cur)) {
	cur += 1;	
    } 
    return cur;
}

string  convertBase(int num) 
{
    string ans;
    while(num > 0) {
	char ch = num%9 + '0';	
	ans = ch + ans;
	num /= 9;
    }
    return ans;
}

map<char, char> mp;

string match(string num)
{
    string ans;
    for (int i = 0; i < num.size(); i++)
	ans += mp[num[i]];
    return ans;
}

int main(int argc, char **argv)
{
    mp['0'] = '0';
    mp['1'] = '1';
    mp['2'] = '2';
    mp['3'] = '3';
    mp['4'] = '5';
    mp['5'] = '6';
    mp['6'] = '7';
    mp['7'] = '8';
    mp['8'] = '9';

//brute force
    for (int i = 1; i < 50; i++) {
	cout << i << " " << getNum(i)  << "   " << match(convertBase(i)) << endl;
    }

}
